Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript: Preserve decorated definite class properties #11129

Conversation

jamescdavis
Copy link
Contributor

Q                       A
Fixed Issues?
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This is a follow-up to #8238, but for class properties marked as definite (using the non-null assertion !)

Current behavior:

The babel-plugin-transform-typescript removes class properties marked as definite regardless if decorators are assigned to it or not.

// Original
class C {
  @foo
  d;
  @foo
  e = 3;
  @foo
  f!;
}

// Transformed
class C {
  @foo
  d;
  @foo
  e = 3;
  // <-- Missing `f` field
}

Expected behavior:

The babel-plugin-transform-typescript should only remove a definite class property if it has no decorators.

// Original
class C {
  @foo
  d;
  @foo
  e = 3;
  @foo
  f!;
}

// Transformed
class C {
  @foo
  d;
  @foo
  e = 3;
  @foo
  f;
}

@nicolo-ribaudo
Copy link
Member

Thanks!

@jamescdavis jamescdavis force-pushed the preserve_decorated_definite_class_properties branch from af70f4b to 5e7a0d7 Compare February 27, 2020 20:08
@JLHwung
Copy link
Contributor

JLHwung commented Feb 27, 2020

@jamescdavis Can you rebase on upstream master? The e2e error will be fixed after rebasing.

@nicolo-ribaudo nicolo-ribaudo merged commit a5f6329 into babel:master Feb 27, 2020
@jamescdavis jamescdavis deleted the preserve_decorated_definite_class_properties branch February 28, 2020 14:10
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 30, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants